<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
key: <input id="key" value=""><input type="button" id="btn" value="ok">
<br/>
msg: <input id="msg" type="text" value=""/>
</body>
</html>
<script type='text/javascript' src='https://code.jquery.com/jquery-3.3.1.min.js'></script>
<script type="text/javascript">
    $(document).ready(function () {
        function pull(key) {
            try {
                $.get("http://localhost:8080/test/pull?key=" + key, function (data) {
                    $("#msg").val(data);
                    pull(key);
                });
            } catch (e) {
                pull(key);
            }
        }

        $("#btn").on("click", function () {
            pull($("#key").val());
        })
    });
</script>